#include <termios.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <pthread.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <stdbool.h>
#include <unistd.h>

#define USLEEP(X) do{nanosleep(&(struct timespec){.tv_sec = 0, .tv_nsec = X*1000}, NULL);}while(false);
#define UNUSED(x) (void)(x)

int setup_device(char * name, int * fd);
int send_device(int fd, char * str);
int read_device(int fd, char ** strptr);
int close_device(int * fd);

char * trim(char ** strptr);

int wait_for_signal(int fd, char * signal, int max_retries);

int disconnect(int fd);

